Removing and Replacing Items in a Picture
You can use theGXSetPicture
function or theGXSetPictureParts
function to replace items in a picture.The
GXSetPicture
function removes every item in a picture and inserts a new list of items. TheGXSetPictureParts
function allows you more control in replacing items. With this function, you can replace a subset of the items in a picture with another set of items. The inserted set does not have to have the same number of items as the replaced set.As a simple example, you can use the
GXSetPictureParts
function to remove a single item from a picture. Listing 6-6 shows how to use theGXSetPictureParts
function to remove the chimney, which is item number 3, from the house picture shown in
Figure 6-21.Listing 6-6 Removing an item from a picture
GXSetPictureParts(housePicture, 3, /* start editing at item 3 */ 1, /* remove 1 item */ 0, /* insert 0 items */ nil, /* no shapes to insert */ nil, nil, nil); /* no overrides */The resulting picture is shown in Figure 6-22.Figure 6-22 A house with chimney removed
You can also use the
GXSetPictureParts
function to replace items in a picture; with a single call toGXSetPictureParts
, you can remove items from a picture and insert new items into a picture.Like the sample code in Listing 6-6, the sample code in Listing 6-7 uses the
GXSetPictureParts
function to remove the chimney shape from the house picture. However, this call to theGXSetPictureParts
function inserts a new chimney into the house picture at the same time.Listing 6-7 Replacing one shape with another
gxShape newChimneyRectangle; gxRectangle newChimneyGeometry = {ff(170), ff(50), ff(180), ff(80)}; . . . newChimneyRectangle = GXNewRectangle(&newChimneyGeometry); SetShapeCommonColor(newChimneyRectangle, dark + gxGray); GXSetPictureParts(housePicture, 3, /* start editing at item 3 */ 1, /* remove 1 item */ 1, /* insert 1 item */ &newChimneyRectangle, /* shape to insert */ nil, nil, nil); /* no overrides */ GXDisposeShape(newChimneyRectangle);The resulting house picture is shown in Figure 6-23.Figure 6-23 A house with the chimney replaced
For more information about the
GXSetPictureParts
function, see page 6-65.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help